package com.ithuangyl.home;

import android.content.Intent;
import android.util.Log;
import android.view.View;

import androidx.appcompat.widget.AppCompatTextView;

import com.ithuangyl.annotation.BindPath;
import com.ithuangyl.aroute.ARouter;
import com.ithuangyl.common.base.BaseFragment;
import com.ithuangyl.common.loader.LoaderStyle;
import com.ithuangyl.common.net.RestClient;
import com.ithuangyl.common.net.callback.ISuccess;

import java.util.HashMap;


@BindPath("fragment/home")
public class HomeFragment extends BaseFragment {

    AppCompatTextView vText;

    private int testCount = 0;

    @Override
    protected Object getLayout() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initView(View rootView) {
        vText = $(R.id.id_home_text);
        addClickListener(vText);
    }

    @Override
    protected void initViewed() {
        showData();
    }

    @Override
    public void onViewClicked(int id) {
        ARouter.create().jumpActivity(mActivity,"activity/list-test",null);
//        RestClient.builder()
//                .url("appversion/0/getByType")
//                .loaderStyle(mActivity, LoaderStyle.BallPulseIndicator)
//                .params(new HashMap<>())
//                .clazz(VersionInfo.class)
//                .success((ISuccess<VersionInfo>) info -> {
//                    Log.e("TAG", "onSuccess" + info.data.version);
//                })
//                .failure((code, message) -> Log.e("TAG", "onFailure" + message))
//                .error((code, message) -> Log.e("TAG", "onError" + message))
//                .build()
//                .get();
    }

    public void doSomething() {
        testCount++;
        showData();
    }

    private void showData() {
        vText.setText("doSomething testCount = " + testCount);
        Log.e("TAG", "HomeFragment.doSomething() testCount = " + testCount);
    }
}
